# -*- coding: utf-8 -*-
"""
Tencent is pleased to support the open source community by making 蓝鲸智云PaaS平台社区版 (BlueKing PaaS Community
Edition) available.
Copyright (C) 2017 THL A29 Limited, a Tencent company. All rights reserved.
Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://opensource.org/licenses/MIT
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from django.db import models


# Create your models here.
class BackUpRecord(models.Model):
    bk_host_id = models.IntegerField(verbose_name='主机ID')
    bk_file_dir = models.CharField(max_length=128, verbose_name='备份文件目录')
    bk_file_suffix = models.CharField(max_length=128, verbose_name='备份文件后缀')
    bk_backup_name = models.CharField(max_length=128, verbose_name='备份文件名称')
    bk_backup_time = models.DateTimeField(verbose_name='备份时间')
    bk_file_operator = models.CharField(max_length=128, verbose_name='备份操作人')
    bk_job_link = models.CharField(max_length=128, verbose_name='JOB结果')

    class Meta:
        verbose_name = '备份记录'
        verbose_name_plural = verbose_name


class ApiRequestCount(models.Model):
    """
    api请求次数的记录模型
    共有三个字段 category, count,name
    """
    api_category = models.CharField(max_length=255, verbose_name='api分类')
    api_count = models.IntegerField(verbose_name='api请求次数')
    api_name = models.CharField(max_length=255, verbose_name='api名称')

    class Meta:
        unique_together = ('api_category', 'api_name')  # 唯一联合索引
        verbose_name = 'api请求次数'
        verbose_name_plural = verbose_name

    def __str__(self) -> str:
        return self.api_category + self.api_name
